package club.beimeng.emailserver.utils;

import lombok.Data;
import org.springframework.beans.factory.InitializingBean;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.context.annotation.PropertySource;
import org.springframework.stereotype.Component;

import java.util.List;

@Data
@Component
@ConfigurationProperties(prefix = "club.beimeng.email")
public class Property implements InitializingBean{
    public List<Account> accounts;

    int threads;// 配置最多的线程数量

    int timeDelay; // 单个账号最短发送冷却时间

    String signature; // 发件人签名

    /*定义一些公开的静态的常量*/
    public static int THREADS;
    public static int TIME_DELAY;;
    public static String SIGNATURE;
    public static List<Account> ACCOUNTS;

    @Override
    public void afterPropertiesSet() throws Exception {
        THREADS = threads;
        TIME_DELAY = timeDelay;
        SIGNATURE = signature;
        ACCOUNTS = accounts;
    }

    @Data
    public static class Account{
        private String emailNumber;

        private String emailCode;
    }

}
